package org.s170.servlet.HouTaiServlet;

import org.s170.dao.AdmintratoDao;
import org.s170.servlet.BaseServlet;
import org.s170.utils.JwtUtil;
import org.s170.vo.ResultVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/admin/admindelete")
public class AdminDeleteServlet extends BaseServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取客户端发送过来的token
        // String token = req.getParameter("token");
        String token = req.getHeader("Authorization");

        // 获取payload信息
        String username = JwtUtil.getPayload(token, "username", String.class);

        Map<String,String> map = parseMap(req);
        String id=map.get("adminID");
        AdmintratoDao dao=new AdmintratoDao();
        int row=dao.delete(id);
       // ResultVO dto=successJson();
        print(resp, successJson());
    }
}
